#pragma once

/* Includes ----------------------------------------------------------------- */
#include "../bsp/bsp_tim.h"
#include "../device/cmd.h"

/* Exported constants ------------------------------------------------------- */
/* PD0-->DI PD1-->DO
   PD3-->CS PD2-->CLK */
#define DI HAL_GPIO_ReadPin(SPI_DIN_GPIO_Port, SPI_DIN_Pin)
#define DO_H HAL_GPIO_WritePin(SPI_DOUT_GPIO_Port, SPI_DOUT_Pin, GPIO_PIN_SET)
#define DO_L HAL_GPIO_WritePin(SPI_DOUT_GPIO_Port, SPI_DOUT_Pin, GPIO_PIN_RESET)
#define CS_H HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET)
#define CS_L HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET)
#define CLK_H HAL_GPIO_WritePin(SPI_CLK_GPIO_Port, SPI_CLK_Pin, GPIO_PIN_SET)
#define CLK_L HAL_GPIO_WritePin(SPI_CLK_GPIO_Port, SPI_CLK_Pin, GPIO_PIN_RESET)

/* Exported macro ----------------------------------------------------------- */
/* Exported types ----------------------------------------------------------- */

typedef struct {
  uint8_t address;
  uint16_t button;
  struct {
    float x;
    float y;
  } ch_left;
  struct {
    float x;
    float y;
  } ch_right;
} PS2_Data_t;
/* Exported functions prototypes -------------------------------------------- */
void PS2_SetInit(PS2_Data_t *ps2);
void PS2_GetRawData(PS2_Data_t *ps2);
void PS2_BehaviorPrase(PS2_Data_t ps2, Cmd_t *cmd);
